package x2rel.qMap.core;

import org.w3c.dom.Node;

public class Variables {

    private Integer cod;
    private Node node;
    private String name;
    private String alias; // pro return
    private String value;
    private String reference; // referencia ao passo anterior (na montagem do xpath)
    private String xpath;
    private Variables varRef; //
    private Variables varValue;
    private String document;
    private Boolean type;
    private String where;
    private String where_op;

    public Variables() {
        this.cod = 0;
        this.name = "";
        this.value = "";
        this.reference = "";
        this.alias = "";
        this.xpath = "";
        this.node = null;
        this.varRef = null;
        this.varValue = null;
        this.document = "";
        this.type = false;
        this.where = "";
        this.where_op = "";
    }

    public Variables(Boolean type) {
        this.name = "";
        this.value = "";
        this.reference = "";
        this.alias = "";
        this.xpath = "";
        this.node = null;
        this.varRef = null;
        this.varValue = null;
        this.type = type;
    }

    @Override
    public String toString() {
        String result =
                "\nnome: " + name
                + "\nvalor:" + value
                + "\nreferência:" + reference
                + "\nxpath:" + xpath;

        if (varRef != null) {
            result += "\nVarRef:"
                    + "\n\tnome:" + varRef.getName()
                    + "\n\tvalue:" + varRef.getValue()
                    + "\n\tref:" + varRef.getReference();
            if (varRef.getVarValue() != null) {
                result += "\n\tVarValue:"
                        + "\n\t\tnome:" + varRef.getVarValue().getName()
                        + "\n\t\tvalue:" + varRef.getVarValue().getValue()
                        + "\n\t\tref:" + varRef.getVarValue().getReference();
            }
            if (varRef.getVarRef() != null) {
                result += "\n\tVarRef:"
                        + "\n\t\tnome:" + varRef.getVarRef().getName()
                        + "\n\t\tvalue:" + varRef.getVarRef().getValue()
                        + "\n\t\tref:" + varRef.getVarRef().getReference();
            }
        }
        if (varValue != null) {
            result += "\nVarValue:"
                    + "\n\tnome:" + varValue.getName()
                    + "\n\tvalue:" + varValue.getValue()
                    + "\n\tref:" + varValue.getReference();
            if (varValue.getVarValue() != null) {
                result += "\n\tVarValue:"
                        + "\n\t\tnome:" + varValue.getVarValue().getName()
                        + "\n\t\tvalue:" + varValue.getVarValue().getValue()
                        + "\n\t\tref:" + varValue.getVarValue().getReference();
            }
            if (varValue.getVarRef() != null) {
                result += "\n\tVarRef:"
                        + "\n\t\tnome:" + varValue.getVarRef().getName()
                        + "\n\t\tvalue:" + varValue.getVarRef().getValue()
                        + "\n\t\tref:" + varValue.getVarRef().getReference();
            }
        }

        return result;

    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the reference
     */
    public String getReference() {
        return reference;
    }

    /**
     * @param reference the reference to set
     */
    public void setReference(String document) {
        this.reference = document;
    }

    /**
     * @return the xpath
     */
    public String getXpath() {
        return xpath;
    }

    /**
     * @param xpath the xpath to set
     */
    public void setXpath(String xpath) {
        this.xpath = xpath;
    }

    /**
     * @return the node
     */
    public Node getNode() {
        return node;
    }

    /**
     * @param node the node to set
     */
    public void setNode(Node node) {
        this.node = node;
    }

    /**
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * @return the varRef
     */
    public Variables getVarRef() {
        return varRef;
    }

    /**
     * @param varRef the varRef to set
     */
    public void setVarRef(Variables varRef) {
        this.varRef = varRef;
    }

    /**
     * @return the varValue
     */
    public Variables getVarValue() {
        return varValue;
    }

    /**
     * @param varValue the varValue to set
     */
    public void setVarValue(Variables varValue) {
        this.varValue = varValue;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public Boolean getType() {
        return type;
    }

    public void setType(Boolean type) {
        this.type = type;
    }

    public String getDocument() {
        return document;
    }

    public void setDocument(String document) {
        this.document = document;
    }

    public String getWhere() {
        return where;
    }

    public void setWhere(String where) {
        this.where = where;
    }

    public String getWhere_op() {
        return where_op;
    }

    public void setWhere_op(String where_op) {
        this.where_op = where_op;
    }

    public Integer getCod() {
        return cod;
    }

    public void setCod(Integer cod) {
        this.cod = cod;
    }
}
